@model IEnumerable<StudentModel>

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>学生列表</title>

    <style>
        /* 页面整体样式 */
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f7f6;
            color: #333;
            padding: 20px;
        }

        h2 {
            text-align: center;
            margin-bottom: 30px;
            color: #2c3e50;
        }

        /* 表格样式 */
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
            background-color: #fff;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        th,
        td {
            padding: 12px;
            text-align: left;
            border: 1px solid #ddd;
        }

        th {
            background-color: #3498db;
            color: white;
            font-weight: bold;
        }

        td {
            background-color: #f9f9f9;
        }

        td button {
            padding: 6px 12px;
            font-size: 14px;
            margin: 2px;
            border-radius: 4px;
            border: none;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        td button:hover {
            opacity: 0.8;
        }

        /* 按钮颜色 */
        .add-btn {
            background-color: #2ecc71;
            color: white;
            padding: 10px 20px;
            font-size: 16px;
            border-radius: 5px;
            text-align: center;
            margin-bottom: 20px;
            cursor: pointer;
            border: none;
            transition: background-color 0.3s ease;
        }

        .add-btn:hover {
            background-color: #27ae60;
        }

        .delete-btn {
            background-color: #e74c3c;
            color: white;
        }

        .edit-btn {
            background-color: #f39c12;
            color: white;
        }

        /* 处理空数据情况 */
        .no-data {
            text-align: center;
            font-size: 18px;
            color: #999;
        }
    </style>
</head>

<body>
    <h2>学生列表</h2>

    <!-- 添加学生按钮 -->
    @using (Html.BeginForm("Add", "Manager", FormMethod.Get))
    {
        <div style="text-align: center;">
            <button type="submit" class="add-btn">添加学生</button>
        </div>
    }

    <!-- 学生列表表格 -->
    <table>
        <thead>
            <tr>
                <th>学号</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var student in Model)
            {
                <tr>
                    <td>@student.StuNum</td>
                    <td>@student.StuName</td>
                    <td>@student.StuAge</td>
                    <td>
                        <!-- 删除按钮 -->
                        @using (Html.BeginForm("Delete", "Manager", new { id = student.StuNum }, FormMethod.Post))
                        {
                            <button type="submit" class="delete-btn">删除</button>
                        }

                        <!-- 修改按钮 -->
                        @using (Html.BeginForm("Edit", "Manager", new { id = student.StuNum }, FormMethod.Get))
                        {
                            <button type="submit" class="edit-btn">修改</button>
                        }
                    </td>
                </tr>
            }

            @if (!Model.Any())
            {
                <tr>
                    <td colspan="4" class="no-data">没有学生记录</td>
                </tr>
            }
        </tbody>
    </table>
</body>

</html>
